package com.hgw.Demo01_SimpleFactory.static_factory;

/**
 * Data time:2021/12/11 16:15
 * StudentID:2019112118
 * Author:hgw
 * Description: 简单咖啡工厂类，充当工厂类
 */
public class SimpleCoffeeFactory {

    public static Coffee createCoffee(String type) {
        // 生命Coffee类型的变量，根据不同类型创建不同的coffee类
        Coffee coffee = null;
        if ("latte".equals(type)) {
            coffee = new LatteCoffee();
        } else if ("american".equals(type)) {
            coffee = new AmericanCoffee();
        } else {
            throw new RuntimeException("对不起，您所点的咖啡没有");
        }
        return coffee;
    }
}
